<?php
class NParseUrl
{
	public static function getUrlinfo($pUrl,$user_url='')
	  {
			$user_url_arr = parse_url($user_url);
			$fullUrl = '';
			if(!strpos($pUrl,"://")){
				$pUrl = parse_url($pUrl);
				if(!isset($pUrl['scheme'])){
					$scheme = "http";
				}else $scheme = $pUrl['scheme'];

				if(!isset($pUrl['host'])){
					if(isset($user_url_arr['host'])){
						$host = $user_url_arr['host'];
					}else $host = $user_url;
				}else $host = $pUrl['host'];
				if(!isset($pUrl['host'])){
					if(isset($user_url_arr['port'])){
						$port = $user_url_arr['port'];
					}else $port = '';
				}else $port = $pUrl['port'];

				if(!isset($pUrl['path'])){
					if(isset($user_url_arr['path'])){
						$path = $user_url_arr['path'];
					}else $path = '';
				}else $path = $pUrl['path'];

				$fullUrl = $scheme . '://' . $host . $port . $path;
			}else{
				$fullUrl = $pUrl;
			}
			return ($fullUrl);
					
	  }
}